#include <bits/stdc++.h>
using namespace std;
struct aaaa{
    long long x=0;
    long long y;
};
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        long long n,sum=0;
        cin>>n;
        long long a[n+5];
        for(long long i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
        long long p=0;
        aaaa b[n];
        for(long long i=0;i<n;i++){
            b[p].x++;
            b[p].y=a[i];
            if(a[i+1]!=a[i])p++;
        }
        for(long long i=0;i<p;i++){
            if(b[i].x!=1)sum+=b[i].y*b[i].x/2;
        }
        cout<<sum<<endl;
    }
    return 0;
}
